<?php
	class Maccount extends CI_Model{
		public function __construct(){
			parent::__construct();
			$this->load->database();
		}
		public function list_account($type)
		{
			if($type==-1)
			$result=$this->db->query("SELECT a.id,a.name,a.email,a.status,a.type,a.join_day FROM account a ORDER BY a.join_day DESC ");
			else
			$result=$this->db->query("SELECT a.id,a.name,a.email,a.status,a.type,a.join_day FROM account a WHERE a.type='$type' ORDER BY a.join_day DESC ");
			return $result->result_array();
		}
		public function list_account_search($m_start,$m_end,$m_name)
		{
			$result=$this->db->query("SELECT a.id,a.name,a.email,a.status,a.type,a.join_day FROM account a WHERE a.name like '%$m_name%' AND a.join_day>='$m_start 00:00:00' AND a.join_day<='$m_end 23:59:59' ORDER BY a.join_day DESC ");
			return $result->result_array();
		}
		public function acc_detail($aid)
		{
			$result=$this->db->query("SELECT a.*,c.`name` as ncity,d.`name` as ndistrict FROM account a,city c,district d WHERE a.city=c.id AND a.district=d.id AND a.id='$aid' ");
			return $result->result_array();
		}
		public function close_account($aid)
		{
			$result=$this->db->query("UPDATE `account` SET `status`='0' WHERE (`id`='$aid')");
		}
	}
?>